import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDMission {
	/**ID*/
	id,
	/**1.主线2.日常3.日常活跃度11-13.成就[养成、战斗、资源]4.在线奖励5.转盘抽奖6.新兵试炼活跃度7.新兵试炼8.竞技场挑战*/
	group,
	/**任务类型--1.成就[永久任务]2.每日任务3.每周任务4.每月任务5.活动任务6.委托任务*/
	missionType,
	/**所需等级*/
	reqLevel,
	/**所需vip等级*/
	reqVip,
	/**天数开启限制*/
	limitDay,
	/**排列顺序--(11-13)成就类型相同排序只显示一个*/
	order,
	/**排序2*/
	order2,
	/**活动开启索引--等级300-500*/
	activityIndex,
	/**触发活动id*/
	activityTigger,
	/**活动id*/
	activityID,
	/**任务名称*/
	name,
	/**任务描述*/
	desc,
	/**主任务标题*/
	title,
	/**主任务描述*/
	dec,
	/**前置任务*/
	preTask,
	/**事件类型1*/
	taskType_1,
	/**事件条件值1-1*/
	taskValue_1_1,
	/**事件条件值1-2*/
	taskValue_1_2,
	/**事件务条件值1-3*/
	taskValue_1_3,
	/**事件类型2*/
	taskType_2,
	/**事件条件值2-1*/
	taskValue_2_1,
	/**事件条件值2-2*/
	taskValue_2_2,
	/**事件条件值2-3*/
	taskValue_2_3,
	/**任务奖励*/
	reward,
	/**图片*/
	icon,
	/**跳转界面id*/
	jumpID,
	/**是否需要消息播报*/
	messageMark,

	/**枚举数量*/
	EnumCount
}



export class CDMission{
	/**ID*/
	public id: number;
	/**1.主线2.日常3.日常活跃度11-13.成就[养成、战斗、资源]4.在线奖励5.转盘抽奖6.新兵试炼活跃度7.新兵试炼8.竞技场挑战*/
	public group: number;
	/**任务类型--1.成就[永久任务]2.每日任务3.每周任务4.每月任务5.活动任务6.委托任务*/
	public missionType: number;
	/**所需等级*/
	public reqLevel: number;
	/**所需vip等级*/
	public reqVip: number;
	/**天数开启限制*/
	public limitDay: number;
	/**排列顺序--(11-13)成就类型相同排序只显示一个*/
	public order: number;
	/**排序2*/
	public order2: number;
	/**活动开启索引--等级300-500*/
	public activityIndex: number;
	/**触发活动id*/
	public activityTigger: number;
	/**活动id*/
	public activityID: number;
	/**任务名称*/
	public name: number;
	/**任务描述*/
	public desc: number;
	/**主任务标题*/
	public title: number;
	/**主任务描述*/
	public dec: number;
	/**前置任务*/
	public preTask: number;
	/**事件类型1*/
	public taskType_1: number;
	/**事件条件值1-1*/
	public taskValue_1_1: number;
	/**事件条件值1-2*/
	public taskValue_1_2: number;
	/**事件务条件值1-3*/
	public taskValue_1_3: number;
	/**事件类型2*/
	public taskType_2: number;
	/**事件条件值2-1*/
	public taskValue_2_1: number;
	/**事件条件值2-2*/
	public taskValue_2_2: number;
	/**事件条件值2-3*/
	public taskValue_2_3: number;
	/**任务奖励*/
	public reward: number;
	/**图片*/
	public icon: string;
	/**跳转界面id*/
	public jumpID: number;
	/**是否需要消息播报*/
	public messageMark: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDMission.id: return this.id;
			case E_CDMission.group: return this.group;
			case E_CDMission.missionType: return this.missionType;
			case E_CDMission.reqLevel: return this.reqLevel;
			case E_CDMission.reqVip: return this.reqVip;
			case E_CDMission.limitDay: return this.limitDay;
			case E_CDMission.order: return this.order;
			case E_CDMission.order2: return this.order2;
			case E_CDMission.activityIndex: return this.activityIndex;
			case E_CDMission.activityTigger: return this.activityTigger;
			case E_CDMission.activityID: return this.activityID;
			case E_CDMission.name: return this.name;
			case E_CDMission.desc: return this.desc;
			case E_CDMission.title: return this.title;
			case E_CDMission.dec: return this.dec;
			case E_CDMission.preTask: return this.preTask;
			case E_CDMission.taskType_1: return this.taskType_1;
			case E_CDMission.taskValue_1_1: return this.taskValue_1_1;
			case E_CDMission.taskValue_1_2: return this.taskValue_1_2;
			case E_CDMission.taskValue_1_3: return this.taskValue_1_3;
			case E_CDMission.taskType_2: return this.taskType_2;
			case E_CDMission.taskValue_2_1: return this.taskValue_2_1;
			case E_CDMission.taskValue_2_2: return this.taskValue_2_2;
			case E_CDMission.taskValue_2_3: return this.taskValue_2_3;
			case E_CDMission.reward: return this.reward;
			case E_CDMission.icon: return this.icon;
			case E_CDMission.jumpID: return this.jumpID;
			case E_CDMission.messageMark: return this.messageMark;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDMission.id: this.id = v; break;
			case E_CDMission.group: this.group = v; break;
			case E_CDMission.missionType: this.missionType = v; break;
			case E_CDMission.reqLevel: this.reqLevel = v; break;
			case E_CDMission.reqVip: this.reqVip = v; break;
			case E_CDMission.limitDay: this.limitDay = v; break;
			case E_CDMission.order: this.order = v; break;
			case E_CDMission.order2: this.order2 = v; break;
			case E_CDMission.activityIndex: this.activityIndex = v; break;
			case E_CDMission.activityTigger: this.activityTigger = v; break;
			case E_CDMission.activityID: this.activityID = v; break;
			case E_CDMission.name: this.name = v; break;
			case E_CDMission.desc: this.desc = v; break;
			case E_CDMission.title: this.title = v; break;
			case E_CDMission.dec: this.dec = v; break;
			case E_CDMission.preTask: this.preTask = v; break;
			case E_CDMission.taskType_1: this.taskType_1 = v; break;
			case E_CDMission.taskValue_1_1: this.taskValue_1_1 = v; break;
			case E_CDMission.taskValue_1_2: this.taskValue_1_2 = v; break;
			case E_CDMission.taskValue_1_3: this.taskValue_1_3 = v; break;
			case E_CDMission.taskType_2: this.taskType_2 = v; break;
			case E_CDMission.taskValue_2_1: this.taskValue_2_1 = v; break;
			case E_CDMission.taskValue_2_2: this.taskValue_2_2 = v; break;
			case E_CDMission.taskValue_2_3: this.taskValue_2_3 = v; break;
			case E_CDMission.reward: this.reward = v; break;
			case E_CDMission.icon: this.icon = v; break;
			case E_CDMission.jumpID: this.jumpID = v; break;
			case E_CDMission.messageMark: this.messageMark = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDMission> = new HashMap<number, CDMission>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDMission[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDMission();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].group = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].missionType = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].reqLevel = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].reqVip = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].limitDay = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].order = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].order2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].activityIndex = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].activityTigger = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].activityID = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].title = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dec = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].preTask = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].taskType_1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].taskValue_1_1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].taskValue_1_2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].taskValue_1_3 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].taskType_2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].taskValue_2_1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].taskValue_2_2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].taskValue_2_3 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].reward = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].icon = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].jumpID = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].messageMark = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDMission{
		return this.datas ? this.datas.get(id) : null;
	}
}
